CREATE TABLE [dbo].[TTERRO_INTE]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[NU_CNTB_EMPR] [dbo].[TD_IN_001_CONT] NOT NULL,
[CO_UNID_CNTB] [dbo].[TD_VC_003] NOT NULL,
[CO_OPRC_CNTB] [dbo].[TD_VC_003] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NOT NULL CONSTRAINT [DF__TTERRO_IN__NU_AN__3DB3258D] DEFAULT (datepart(year,getdate())),
[NU_MESE] [dbo].[TD_IN_002_MESE] NOT NULL,
[NU_ASTO] [dbo].[TD_VC_010] NOT NULL,
[NU_SECU] [dbo].[TD_IN_002] NOT NULL,
[FE_ASTO_CNTB] [dbo].[TD_DT_001] NOT NULL,
[CO_CNTA_EMPR] [dbo].[TD_VC_020_CNTA] NOT NULL,
[TI_AUXI_EMPR] [dbo].[TD_VC_001] NULL,
[CO_AUXI_EMPR] [dbo].[TD_VC_020] NULL,
[TI_DOCU] [dbo].[TD_VC_003] NULL,
[NU_DOCU] [dbo].[TD_VC_020] NULL,
[FE_DOCU] [dbo].[TD_DT_001] NULL,
[FE_DOCU_VENC] [dbo].[TD_DT_001] NULL,
[TI_CAMB] [dbo].[TD_VC_003] NOT NULL,
[CO_MONE] [dbo].[TD_VC_003] NOT NULL,
[FA_CAMB] [dbo].[TD_NU_015_006] NOT NULL CONSTRAINT [DF__TTERRO_IN__FA_CA__408F9238] DEFAULT ((1.000)),
[FA_CAMB_DIAR] [dbo].[TD_NU_015_006] NOT NULL CONSTRAINT [DF__TTERRO_IN__FA_CA__4277DAAA] DEFAULT ((1.000)),
[TI_OPER] [dbo].[TD_VC_003] NOT NULL,
[IM_MVTO_ORIG] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TTERRO_IN__IM_MV__4460231C] DEFAULT ((0)),
[IM_MVTO_CNTB] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TTERRO_IN__IM_MV__45544755] DEFAULT ((0)),
[DE_GLOS] [dbo].[TD_VC_100] NOT NULL,
[TI_DOCU_REFE] [dbo].[TD_VC_003] NULL,
[NU_DOCU_REFE] [dbo].[TD_VC_020] NULL,
[FE_DOCU_REFE] [dbo].[TD_DT_001] NULL,
[NO_GIRA] [dbo].[TD_VC_050] NULL,
[FE_ENTR_CHEQ] [dbo].[TD_DT_001] NULL,
[FE_PROG_CHEQ] [dbo].[TD_DT_001] NULL,
[CO_ORDE_SERV] [dbo].[TD_VC_020] NULL,
[SI_MVTO_CNTB] [dbo].[TD_VC_003] NOT NULL,
[CO_UNID_ORIG] [dbo].[TD_VC_003] NULL,
[CO_OPRC_ORIG] [dbo].[TD_VC_003] NULL,
[NU_ASTO_ORIG] [dbo].[TD_VC_010] NULL,
[ST_OTRS] [dbo].[TD_VC_020] NULL,
[NU_PROC] [dbo].[TD_IN_001] NULL,
[NU_PROC_SECU] [dbo].[TD_IN_001] NULL,
[ST_IMPR_CHEQ] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TTERRO_IN__ST_IM__46486B8E] DEFAULT ('N'),
[ST_FLAG] [dbo].[TD_VC_020] NULL,
[DE_ERRO] [dbo].[TD_VC_100] NULL,
[CO_TABL_ORIG] [dbo].[TD_IN_001] NULL,
[CO_CLAV_TAOR] [dbo].[TD_VC_100] NULL,
[CO_TIPO_OPER] [dbo].[TD_VC_003] NULL,
[IM_MVTO_RETE] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TTERRO_IN__IM_MV__4830B400] DEFAULT ((0)),
[ST_IMPR_RETE] [dbo].[TD_VC_001_SINO] NOT NULL CONSTRAINT [DF__TTERRO_IN__ST_IM__4A18FC72] DEFAULT ('N'),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TTERRO_IN__FE_US__4C0144E4] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TTERRO_INTE] ADD CONSTRAINT [CK__TTERRO_IN__FA_CA__4183B671] CHECK (([FA_CAMB]>=(0)))
GO
ALTER TABLE [dbo].[TTERRO_INTE] ADD CONSTRAINT [CK__TTERRO_IN__FA_CA__436BFEE3] CHECK (([FA_CAMB_DIAR]>=(0)))
GO
ALTER TABLE [dbo].[TTERRO_INTE] ADD CONSTRAINT [CK__TTERRO_IN__IM_MV__4924D839] CHECK (([IM_MVTO_RETE]>=(0)))
GO
ALTER TABLE [dbo].[TTERRO_INTE] ADD CONSTRAINT [CK__TTERRO_IN__NU_AN__3EA749C6] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TTERRO_INTE] ADD CONSTRAINT [CK__TTERRO_IN__NU_CN__3CBF0154] CHECK (([NU_CNTB_EMPR]>=(1) AND [NU_CNTB_EMPR]<=(99)))
GO
ALTER TABLE [dbo].[TTERRO_INTE] ADD CONSTRAINT [CK__TTERRO_IN__NU_ME__3F9B6DFF] CHECK (([NU_MESE]>=(0) AND [NU_MESE]<=(13)))
GO
ALTER TABLE [dbo].[TTERRO_INTE] ADD CONSTRAINT [CK__TTERRO_IN__ST_IM__473C8FC7] CHECK (([ST_IMPR_CHEQ]='N' OR [ST_IMPR_CHEQ]='S'))
GO
ALTER TABLE [dbo].[TTERRO_INTE] ADD CONSTRAINT [CK__TTERRO_IN__ST_IM__4B0D20AB] CHECK (([ST_IMPR_RETE]='N' OR [ST_IMPR_RETE]='S'))
GO
